package helloWorld;

import org.mt4j.MTApplication;
import org.mt4j.components.interfaces.IMTComponent3D;
import org.mt4j.components.visibleComponents.widgets.MTImage;
import org.mt4j.input.inputProcessors.IGestureEventListener;
import org.mt4j.input.inputProcessors.MTGestureEvent;
import org.mt4j.input.inputProcessors.componentProcessors.tapProcessor.TapEvent;
import org.mt4j.input.inputProcessors.componentProcessors.zoomProcessor.ZoomEvent;

public class AlbumInfoGestureListener implements IGestureEventListener{
	private MTApplication mtApplication;
	private Controller controller;
	private AlbumInfoScene albumInfoScene;
	public AlbumInfoGestureListener(MTApplication mtApplication, AlbumInfoScene AlbumInfoScene){
		this.mtApplication = mtApplication;
		controller = Controller.getInstance();
		this.albumInfoScene = AlbumInfoScene;
	}

	@Override
	public boolean processGestureEvent(MTGestureEvent ge) {
		if(ge instanceof TapEvent){
			TapEvent te = (TapEvent)ge;
			IMTComponent3D target = te.getTargetComponent();
			if(target instanceof AlbumTrack){
				AlbumTrack track = (AlbumTrack) target;
				switch (te.getTapID()) {
				case TapEvent.BUTTON_DOWN:
					System.out.println("Button down state on " + target);
					break;
				case TapEvent.BUTTON_UP:
					System.out.println("Button up state on " + target);
					break;
				case TapEvent.BUTTON_CLICKED:
					//TODO
					this.albumInfoScene.play(Integer.parseInt(track.getName()));
					System.out.println("JEEEEEEJ!!");
					System.out.println("Clicked " + track.getName());
					break;
				default:
					break;
				}
				
			}
			else if(target instanceof MTImage){
				// go back
				if(target.getName() == "albuminfosceneBACK"){
					mtApplication.changeScene(mtApplication.getScene("AlbumScene"));
				}
				else if(target.getName() == "GLOBEBUTTON"){
					mtApplication.changeScene(mtApplication.getScene("MapsScene"));
				}
			}
		}else if(ge instanceof ZoomEvent){
			
			ZoomEvent ze = (ZoomEvent)ge;
			if(ze.getTargetComponent().getName() == "artistinfocanvas")
			{
				if(ze.getCamZoomAmount() >= 10)
					;//mtApplication.changeScene(mtApplication.getScene("AlbumScene"));
			}
		}
		return false;

	}
}
